/**
 * Chooser Class
 * Chooses a random value from a list and avoids repetition
 * @author Manel Villar
 * 
 * Constructor
 * @param {Array} list
 */

function Chooser(orig) {
	this.list = [];
	
	if (typeof orig == "object") 
		this.setList(orig);
};


Chooser.prototype.setList = function(orig) {

	for (var k =0; k < orig.length; k++ ) {
		this.list[k] = k;
	}
	
}

Chooser.prototype.remove = function(n) {
	this.list.splice(n,1);	
} 


Chooser.prototype.getRandomValue = function() {
	if (this.list.length < 1) return false;
	
	var n = Math.floor(Math.random() * this.list.length);	
	var val = this.list.splice(n,1);
	return val[0];
}

